// LSL script generated: RLV-New.RLV_MENU.DV_RLV_CHAT.lslp Sun May  2 00:09:51 Westeuropäische Sommerzeit 2010
/*
################################################################################################################################# Included
0 2    B  Allow/prevent sending chat messages : "@sendchat=<y/n>" 
1 2    B  Remove/add an exception to the emote truncation above : "@emote=<rem/add>"
2 2    B  Allow/prevent shouting : "@chatshout=<y/n>"
3 2    B  Allow/prevent chatting at normal volume : "@chatnormal=<y/n>"
4 2    B  Allow/prevent whispering : "@chatwhisper=<y/n>"       
5 2    B  Allow/prevent sending instant messages, secure way : "@sendim_sec=<y/n>"     
6 2    B  Allow/prevent receiving chat messages, secure way : "@recvchat_sec=<y/n>"
7 2    B  Allow/prevent receiving instant messages, secure way : "@recvim_sec=<y/n>"
8 2    B  Allow/prevent seeing emotes, secure way : "@recvemote_sec=<y/n>"     
#################################################################################################################################
*/
integer attachment = 1;
string cmdname;
key victim;
list gMenu = [];
list statesMenu = [0,0,0,0,0,0,0,0,0,0];
key ToucherID;
integer channel_dialog;
integer listen_id;
string msg = "Chat Restrictions";
list sideMenu = [" ","Back"," "];

llRlvSay(string command){
    if ((attachment == 1)) {
        llOwnerSay(("@" + command));
    }
    else  {
        llSay(-1812221819,(((((cmdname + ",") + ((string)victim)) + ",") + "@") + command));
    }
}

MakeRLVState(){
    if ((attachment == 1)) {
        if ((llList2Integer(statesMenu,0) == 1)) llRlvSay("sendchat=n");
        if ((llList2Integer(statesMenu,1) == 1)) llRlvSay("emote=rem");
        if ((llList2Integer(statesMenu,2) == 1)) llRlvSay("chatshout=n");
        if ((llList2Integer(statesMenu,3) == 1)) llRlvSay("chatnormal=n");
        if ((llList2Integer(statesMenu,4) == 1)) llRlvSay("chatwhisper=n");
        if ((llList2Integer(statesMenu,5) == 1)) llRlvSay("sendim_sec=n");
        if ((llList2Integer(statesMenu,6) == 1)) llRlvSay("recvchat_sec=n");
        if ((llList2Integer(statesMenu,7) == 1)) llRlvSay("recvim_sec=n");
        if ((llList2Integer(statesMenu,8) == 1)) llRlvSay("recvemote_sec=n");
    }
}

llLRP(integer element_new,integer placeinlist){
    (statesMenu = llListReplaceList(statesMenu,[element_new],placeinlist,placeinlist));
}

makeMenu(){
    (gMenu = []);
    (gMenu += sideMenu);
    if ((llList2Integer(statesMenu,0) == 1)) (gMenu += "[x]Send Chat");
    else  (gMenu += "[ ]Send Chat");
    if ((llList2Integer(statesMenu,1) == 1)) (gMenu += "[x]Long Emote");
    else  (gMenu += "[ ]Long Emote");
    if ((llList2Integer(statesMenu,2) == 1)) (gMenu += "[x]Shout");
    else  (gMenu += "[ ]Shout");
    if ((llList2Integer(statesMenu,3) == 1)) (gMenu += "[x]Normal");
    else  (gMenu += "[ ]Normal");
    if ((llList2Integer(statesMenu,4) == 1)) (gMenu += "[x]Whisper");
    else  (gMenu += "[ ]Whisper");
    if ((llList2Integer(statesMenu,5) == 1)) (gMenu += "[x]Send IM");
    else  (gMenu += "[ ]Send IM");
    if ((llList2Integer(statesMenu,6) == 1)) (gMenu += "[x]Rec. Chat");
    else  (gMenu += "[ ]Rec. Chat");
    if ((llList2Integer(statesMenu,7) == 1)) (gMenu += "[x]Rec. IM");
    else  (gMenu += "[ ]Rec. IM");
    if ((llList2Integer(statesMenu,8) == 1)) (gMenu += "[x]See Emote");
    else  (gMenu += "[ ]See Emote");
    (channel_dialog = (-1 * ((integer)("0x" + llGetSubString(((string)llGetKey()),-5,-1)))));
    (listen_id = llListen(channel_dialog,"",NULL_KEY,""));
    llDialog(ToucherID,msg,gMenu,channel_dialog);
    llSetTimerEvent(45.0);
}

default {

    state_entry() {
    }

    
    listen(integer channel,string name,key id,string message) {
        llSetTimerEvent(0.0);
        llListenRemove(listen_id);
        if ((message == "[x]Send Chat")) {
            llLRP(0,0);
            llRlvSay("sendchat=y");
            makeMenu();
        }
        if ((message == "[ ]Send Chat")) {
            llLRP(1,0);
            llRlvSay("sendchat=n");
            makeMenu();
        }
        if ((message == "[x]Long Emote")) {
            llLRP(0,1);
            llRlvSay("emote=rem");
            makeMenu();
        }
        if ((message == "[ ]Long Emote")) {
            llLRP(1,1);
            llRlvSay("emote=add");
            makeMenu();
        }
        if ((message == "[x]Shout")) {
            llLRP(0,2);
            llRlvSay("chatshout=y");
            makeMenu();
        }
        if ((message == "[ ]Shout")) {
            llLRP(1,2);
            llRlvSay("chatshout=n");
            makeMenu();
        }
        if ((message == "[x]Normal")) {
            llLRP(0,3);
            llRlvSay("chatnormal=y");
            makeMenu();
        }
        if ((message == "[ ]Normal")) {
            llLRP(1,3);
            llRlvSay("chatnormal=n");
            makeMenu();
        }
        if ((message == "[x]Whisper")) {
            llLRP(0,4);
            llRlvSay("chatwhisper=y");
            makeMenu();
        }
        if ((message == "[ ]Whisper")) {
            llLRP(1,4);
            llRlvSay("chatwhisper=n");
            makeMenu();
        }
        if ((message == "[x]Send IM")) {
            llLRP(0,5);
            llRlvSay("sendim_sec=y");
            makeMenu();
        }
        if ((message == "[ ]Send IM")) {
            llLRP(1,5);
            llRlvSay("sendim_sec=n");
            makeMenu();
        }
        if ((message == "[x]Rec. Chat")) {
            llLRP(0,6);
            llRlvSay("recvchat_sec=y");
            makeMenu();
        }
        if ((message == "[ ]Rec. Chat")) {
            llLRP(1,6);
            llRlvSay("recvchat_sec=n");
            makeMenu();
        }
        if ((message == "[x]Rec. IM")) {
            llLRP(0,7);
            llRlvSay("recvim_sec=y");
            makeMenu();
        }
        if ((message == "[ ]Rec. IM")) {
            llLRP(1,7);
            llRlvSay("recvim_sec=n");
            makeMenu();
        }
        if ((message == "[x]See Emote")) {
            llLRP(0,8);
            llRlvSay("recvemote_sec=y");
            makeMenu();
        }
        if ((message == "[ ]See Emote")) {
            llLRP(1,8);
            llRlvSay("recvemote_sec=n");
            makeMenu();
        }
        if ((message == "Back")) llMessageLinked(-4,1337,"DV_MAIN_RLV",ToucherID);
    }

    
    on_rez(integer on) {
    }

    
    link_message(integer sender,integer num,string str,key id) {
        if ((num == 1337)) {
            if ((str == llGetScriptName())) {
                llMessageLinked(-4,1338,llGetScriptName(),NULL_KEY);
                (ToucherID = id);
                makeMenu();
            }
        }
        if ((num == 1338)) {
            if ((str == "attachment")) (attachment = 1);
            else  if ((str == "device")) (attachment = 0);
            else  if ((str != llGetScriptName())) {
                llListenRemove(listen_id);
            }
        }
        if ((num == 1339)) {
            if ((str == "ON_REZ")) {
                MakeRLVState();
            }
            if ((str == "RESET")) {
                (statesMenu = [0,0,0,0,0,0,0,0,0,0]);
            }
        }
        if ((num == 1329)) {
            (victim = ((key)str));
            (cmdname = ((string)llGetKey()));
        }
    }

  	timer() {
        llSetTimerEvent(0.0);
        llListenRemove(listen_id);
    }
}
